﻿#region Librerias

using System;
using ESF.Web;
using ESF.SSO.Presenter.Client;
using ESF.Web.Pages;
using ESF.SSO.Presenter;
using ESF.SSO.Web.Tools.Modules;
using ESF.SSO.Core.Entities.BasicReferences;
using ESF.General;

#endregion


public partial class ContactUs : BasePagePresenter<ContactUsPresenter>, IContactUsViewer
{
	#region Carga Inicial
    
    protected void Page_Load(object sender, EventArgs e)
    {
		if (!IsPostBack)
		{
			if (frmIsAuthenticated)
			{
				UserEmail = AuthenticationModule.SignedInUser.Email;
				
				txtUserEmail.Enabled = false;
			}

			
			if (!string.IsNullOrEmpty (Request.QueryString ["HCF"]))
			{
				divCategoryField.Visible = false;
			}

			ListLoader.LoadList (ddlContactUsType, WebGeneral.ListBasicReference (BasicReferenceTypes.ContactUsType));
			
			if (ListLoader.Select (ddlContactUsType, Request.QueryString ["CFCode"]))
			{
				divCategoryField.Visible = false;
				ddlContactUsType.Enabled = false;
				Title = ddlContactUsType.SelectedItem.Text;
			}

			lblTitle.Text = Title;

			ListLoader.SelectByText(ddlContactUsType, Request.QueryString["pContactUsType"], true);

			txtComment.Text = Request.QueryString["pComment"];

			txtCommentTitle.Text = Request.QueryString["pCommentTitle"];
		}

		_Presenter = new ContactUsPresenter (this);
    }
    
    #endregion
    
    
    #region Eventos de los botones
    
    protected void btnSend_Click(object sender, EventArgs e)
	{
		_Presenter.SendComment ();
	}

	#endregion
	

	#region Miembros de IContactUsViewer

	public int? ContactUsTypeID 
	{
		set { ListLoader.Select (ddlContactUsType, value); }
		get { return TextHelper.GetNullableInt (ddlContactUsType.SelectedValue); }
	}


	public string UserEmail
	{
		get { return txtUserEmail.Text; }
		set { txtUserEmail.Text = value; }
	}

	public string CommentTitle
	{
		get { return txtCommentTitle.Text; }
		set { txtCommentTitle.Text = value; }
	}

	public string Comment
	{
		get { return txtComment.Text; }
		set { txtComment.Text = value; }
	}

	#endregion
}
